package ru.sh;

import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import framework.Game;
import framework.GameActivity;
import framework.GameCamera;
import framework.GameConfig;
import framework.GameRenderer;
import framework.GameResources;

public class SHActivity extends GameActivity {
	
	@Override
	protected GameRenderer getMyRendererInstance() {
		return new SHRenderer();
	}
	
	@Override
	protected void initConfig() {
		GameConfig.BASE_HEIGHT = 640 * 2;
		GameConfig.BASE_WIDTH = 960 * 2;
	}

	@Override
	protected void initResources() {
		GameResources.initBitmapNames(new String[] {
				"game/arrow.png",
				"game/badJewel.png",
				"game/bg_new.jpg",
				"game/fireBtn.png",
				"game/goodJewel.png",
				
				"game/hero.png",
				"game/joy.png",
				"game/moveBtn.png",
				"game/needJewel.png",
				"game/simpleHeart.png",
				
				"game/hero.png",
				"game/heroMap_2_4.png",
				"game/mSimpleHeart.png",
				"game/mShotPanel.png",
				"menu/bg.png",
				
				"menu/playBtn.png",
				"menu/highscoreBtn.png",
				"menu/helpBtn.png",
				"menu/exitBtn.png",
				"menu/soundBtn.png",
				
				"game/pointers.png",
				"game/aim.png",
				"game/test_point.png"
				});
		GameResources.initSoundNames(new String[] {
				"sound/fire.mp3",
				"sound/pre_fire.mp3",
				"sound/good_jewel_getted.mp3",
				"sound/hit_heart.mp3"
				});
	}

	@Override
	protected void initCamera() {
		GameCamera.setPosition(GameConfig.BASE_WIDTH / 2 - GameCamera.CAMERA_WIDTH / 2,
				GameConfig.BASE_HEIGHT / 2 - GameCamera.CAMERA_HEIGHT / 2);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.menu, menu);
	    return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		 switch (item.getItemId()) {
		    case R.id.pause:
		        Game.pause();
		        return true;
		    case R.id.restart:
		    	((SHGame)Game.getInstance()).restart();
		        return true;
		    case R.id.main :
		    	((SHGame)Game.getInstance()).setMenuScreen();
		    	return true;
		    case R.id.exit :
		    	finish();
		    	return true;
		    default:
		        return super.onOptionsItemSelected(item);
		    }

	}
	
}